﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PMS.ENT;
using PMS.DAL;

namespace PMS.BLL
{
    public class GroupBLL
    {
        #region Get
        public static GroupENT GetGroupByID(int groupID)
        {
            try
            {
                return GroupDAL.GetGroupByID(groupID);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public static GroupCollection GetGroupList(string groupName,int semesterID, int projectID, int scheduleID, int userID, string status, string orderBy, string orderDirection, int page, int pageSize, out int totalRecords)
        {
            try
            {
                return GroupDAL.GetGroupList(groupName,semesterID, projectID, scheduleID, userID, status, orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public static GroupCollection GetJoinGroupList(int projectID,int semesterID)
        {
            try
            {
                return GroupDAL.GetJoinGroupList(projectID, semesterID);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public static GroupCollection GetAcceptGroupList(int projectID, int semesterID)
        {
            try
            {
                return GroupDAL.GetAcceptGroupList(projectID, semesterID);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public static GroupCollection GetGroupListForCMB(int userID, int projectID)
        {
            try
            {
                GroupCollection listGroup = new GroupCollection();
                listGroup.Add(new GroupENT { GroupID = 0, GroupName = string.Empty });
                listGroup.AddRange(GroupDAL.GetGroupListForCMB(userID, projectID));
                return listGroup;
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static GroupCollection GetGroupListForCMB()
        {
            try
            {
                GroupCollection listGroup = new GroupCollection();
                listGroup.Add(new GroupENT { GroupID = 0, GroupName = "--All--" });
                listGroup.AddRange(GroupDAL.GetGroupListForCMB());
                return listGroup;
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static GroupCollection GetGroupListByScheduleIDForCMB(int scheduleID,int semesterID)
        {
            try
            {
                GroupCollection listGroup = new GroupCollection();
                listGroup.Add(new GroupENT { GroupID = 0, GroupName = string.Empty });
                listGroup.AddRange(GroupDAL.GetGroupListByScheduleIDForCMB(scheduleID,semesterID));
                return listGroup;
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static GroupCollection GetGroupListJoinByScheduleID(int scheduleID)
        {
            try
            {
                return GroupDAL.GetGroupListJoinByScheduleIDForCMB(scheduleID);
            }
            catch (Exception)
            {

                throw;
            }
        }

        #endregion

        #region Insert Update Delete Confirm

        public static int InsertGroup(GroupENT group)
        {
            try
            {
                return GroupDAL.InsertGroup(group);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static int UpdateGroup(GroupENT group)
        {
            try
            {
                return GroupDAL.UpdateGroup(group);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static int DeleteGroup(string groupID, int userID)
        {
            try
            {
                return GroupDAL.DeleteGroup(groupID, userID);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static int ConfirmGroup(string groupID, int userID)
        {
            try
            {
                return GroupDAL.ConfirmGroup(groupID, userID);
            }
            catch (Exception)
            {

                throw;
            }
        }


        #endregion

        #region Validate

        public static bool CheckIsOwnAndDraft(int[] groupID, int userID)
        {
            try
            {
                return GroupDAL.CheckIsOwnAndDraft(groupID, userID);
            }
            catch (Exception)
            {

                throw;
            }
        }
        public static bool CheckIsOwn(int[] groupID, int userID)
        {
            try
            {
                return GroupDAL.CheckIsOwn(groupID, userID);
            }
            catch (Exception)
            {

                throw;
            }
        }
        public static bool CheckGroupStatus(int[] groupID, string status)
        {
            try
            {
                return GroupDAL.CheckGroupStatus(groupID, status);
            }
            catch (Exception)
            {

                throw;
            }
        }
        #endregion
    }
}
